/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package formularios.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Ramon
 */
@Entity
@Table(name = "IMOVEIS")
@NamedQueries({
    @NamedQuery(name = "Imoveis.findAll", query = "SELECT i FROM Imoveis i"),
    @NamedQuery(name = "Imoveis.findByCod", query = "SELECT i FROM Imoveis i WHERE i.cod = :cod"),
    @NamedQuery(name = "Imoveis.findByNomeCondominio", query = "SELECT i FROM Imoveis i WHERE i.nomeCondominio = :nomeCondominio"),
    @NamedQuery(name = "Imoveis.findByAreaUtil", query = "SELECT i FROM Imoveis i WHERE i.areaUtil = :areaUtil"),
    @NamedQuery(name = "Imoveis.findByPreco", query = "SELECT i FROM Imoveis i WHERE i.preco = :preco"),
    @NamedQuery(name = "Imoveis.findByTipoImovel", query = "SELECT i FROM Imoveis i WHERE i.tipoImovel = :tipoImovel"),
    @NamedQuery(name = "Imoveis.findByVendido", query = "SELECT i FROM Imoveis i WHERE i.vendido = :vendido")})
public class Imoveis implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "COD")
    private Integer cod;
    @Column(name = "NOME_CONDOMINIO")
    private String nomeCondominio;
    @Column(name = "AREA_UTIL")
    private String areaUtil;
    @Basic(optional = false)
    @Column(name = "PRECO")
    private double preco;
    @Basic(optional = false)
    @Column(name = "TIPO_IMOVEL")
    private String tipoImovel;
    @Basic(optional = false)
    @Column(name = "VENDIDO")
    private char vendido;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "imoveis")
    private Collection<Vendas> vendasCollection;
    @JoinColumn(name = "CNPJ_CONST", referencedColumnName = "CNPJ")
    @ManyToOne(optional = false)
    private Construtoras construtoras;

    public Imoveis() {
    }

    public Imoveis(Integer cod) {
        this.cod = cod;
    }

    public Imoveis(Integer cod, Construtoras cnpj_const, String nome_condominio, String area_util,
                   Double preco, String tipo_imovel, char vendido) {
        this.cod = cod;
        this.construtoras = cnpj_const;
        this.nomeCondominio = nome_condominio;
        this.areaUtil = area_util;
        this.preco = preco;
        this.tipoImovel = tipo_imovel;
        this.vendido = vendido;
    }

    public Integer getCod() {
        return cod;
    }

    public void setCod(Integer cod) {
        this.cod = cod;
    }

    public String getNomeCondominio() {
        return nomeCondominio;
    }

    public void setNomeCondominio(String nomeCondominio) {
        this.nomeCondominio = nomeCondominio;
    }

    public String getAreaUtil() {
        return areaUtil;
    }

    public void setAreaUtil(String areaUtil) {
        this.areaUtil = areaUtil;
    }

    public double getPreco() {
        return preco;
    }

    public void setPreco(double preco) {
        this.preco = preco;
    }

    public String getTipoImovel() {
        return tipoImovel;
    }

    public void setTipoImovel(String tipoImovel) {
        this.tipoImovel = tipoImovel;
    }

    public char getVendido() {
        return vendido;
    }

    public void setVendido(char vendido) {
        this.vendido = vendido;
    }

    public Collection<Vendas> getVendasCollection() {
        return vendasCollection;
    }

    public void setVendasCollection(Collection<Vendas> vendasCollection) {
        this.vendasCollection = vendasCollection;
    }

    public Construtoras getConstrutoras() {
        return construtoras;
    }

    public void setConstrutoras(Construtoras construtoras) {
        this.construtoras = construtoras;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cod != null ? cod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Imoveis)) {
            return false;
        }
        Imoveis other = (Imoveis) object;
        if ((this.cod == null && other.cod != null) || (this.cod != null && !this.cod.equals(other.cod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "formularios.model.Imoveis[cod=" + cod + "]";
    }

}
